Skip to content

fix(rhwp-chrome): 썸네일 로딩 스피너 정리 + options CSP 호환#168

Merged
edwardkim merged 5 commits intoedwardkim:develfrom
postmelee:fix/chrome-clean-v2
Apr 17, 2026
Merged

fix(rhwp-chrome): 썸네일 로딩 스피너 정리 + options CSP 호환#168
edwardkim merged 5 commits intoedwardkim:develfrom
postmelee:fix/chrome-clean-v2

Conversation

@postmelee
Copy link
Copy Markdown
Contributor

@postmelee postmelee commented Apr 16, 2026

변경 요약

Chrome 확장에서 두 가지 사용자 체감 이슈를 수정했습니다.

  1. 썸네일 로딩 완료 후에도 모래시계(⏳)가 남아 보이던 문제를 수정했습니다.
    • rhwp-chrome/content-script.js
    • insertThumbnailImg()에서 이미지 삽입 전에 thumbDiv.textContent = ''로 로딩 플레이스홀더를 제거
  2. 옵션 페이지가 비어 보이던 CSP 문제를 수정했습니다.
    • rhwp-chrome/options.html 인라인 스크립트를 제거하고 options.js로 분리
    • rhwp-chrome/options.js는 다른 non-module 스크립트(content-script.js, dev-tools-inject.js)와 동일하게 IIFE + 'use strict' 패턴 적용
    • rhwp-chrome/build.mjs에서 options.jsdist/로 복사하도록 반영

변경 파일:

  • rhwp-chrome/content-script.js
  • rhwp-chrome/options.html
  • rhwp-chrome/options.js (신규)
  • rhwp-chrome/build.mjs

본 PR은 #167을 대체합니다. (close/reopen 흔적 정리 + Copilot 리뷰 반영 커밋 포함)

관련 이슈

closes #86
closes #166

테스트

본 PR 변경 범위는 rhwp-chrome/ 내 JS·HTML·빌드 스크립트에 한정됩니다. Rust 코어(파서/렌더러/WASM)에는 변경이 없으므로 Rust 측 항목은 무관(N/A)이지만 회귀 확인 차원에서 cargo 명령은 실제 실행했습니다.

  • cargo test 통과 — 785 passed, 0 failed (회귀 확인용 실행, 본 PR 변경과 직접 관련 없음)
  • cargo clippy -- -D warnings 통과 — 라이브러리 타겟 깨끗 통과 (회귀 확인용 실행, 본 PR 변경과 직접 관련 없음)
  • 관련 샘플 파일로 SVG 내보내기 확인N/A: Rust 렌더러 무변경 (Chrome 확장 JS만 수정)
  • 웹(WASM) 렌더링 확인N/A: Rust→WASM 빌드 무변경 (Chrome 확장 JS만 수정)
  • cd rhwp-chrome && npm run build 실행
  • Chrome 개발자 모드에서 rhwp-chrome/dist 로드 후 옵션 페이지/썸네일 동작 수동 확인

스크린샷

  • 옵션 페이지: 인라인 스크립트 차단으로 텍스트가 비던 상태에서 정상 텍스트 표시 상태로 개선
변경 전 변경 후
스크린샷 2026-04-16 22 14 13 스크린샷 2026-04-17 02 55 10
  • 썸네일 호버: 로딩 완료 후 스피너 제거되고 썸네일만 표시
    (이상하게 배포버전에서 썸네일이 안 보입니다.)
변경 전 변경 후
스크린샷 2026-04-17 03 07 59 스크린샷 2026-04-17 03 06 45

postmelee and others added 3 commits April 16, 2026 22:40
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot 리뷰 (PR edwardkim#167) 반영 — 다른 non-module 스크립트
(content-script.js, dev-tools-inject.js)와 동일하게 IIFE +
'use strict' 패턴으로 감싸 전역 스코프 오염 방지.
Copilot AI review requested due to automatic review settings April 16, 2026 17:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes two user-visible issues in the rhwp-chrome extension: leftover thumbnail loading spinner after image insertion, and the options page failing under Chrome extension CSP due to inline scripts.

Changes:

  • Clear the thumbnail container placeholder text before appending the loaded thumbnail image.
  • Move options page inline script into a standalone options.js (IIFE + strict mode) and reference it from options.html.
  • Update build.mjs to copy options.js into dist/.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
rhwp-chrome/content-script.js Clears thumbnail placeholder content so the loading spinner doesn’t remain after image insertion.
rhwp-chrome/options.html Removes inline script and loads options.js to comply with extension CSP.
rhwp-chrome/options.js New external options logic (i18n + load/save settings) compatible with CSP.
rhwp-chrome/build.mjs Copies options.js into dist/ so the options page can load it in the built extension.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

postmelee and others added 2 commits April 17, 2026 02:29
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
data-hwp-title="전입신고서"
data-hwp-pages="2"
data-hwp-thumbnail="/thumbs/preview.webp"
data-hwp-thumbnail="https://example.com/thumbs/preview.webp"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rhwpDev.help() 출력 예시에서 사용자에게 보여주는 코드:
data-hwp-thumbnail="/thumbs/preview.webp" ← 상대경로

그러나 실제로 이 속성값을 표시하는 로직(content-script.js:60)은:
function isSafeImageUrl(url) {
try {
const parsed = new URL(url); // ← base 인자 없음
return parsed.protocol === 'https:' || parsed.protocol === 'http:';
} catch { return false; }
}

new URL("/thumbs/preview.webp") 는 base 없으면 TypeError를 던집니다 → catch에서 false → 썸네일 거절.

즉 사용자가 help 가이드를 그대로 따라 data-hwp-thumbnail="/thumbs/preview.webp"라고 적으면 썸네일이
표시되지 않습니다. 가이드와 실제 동작이 어긋나는 상태였습니다.

@edwardkim
Copy link
Copy Markdown
Owner

저도 이거 눈에 거슬렸습니다. ㅎㅎ
수정해주셔서 감사합니다.

Copy link
Copy Markdown
Owner

@edwardkim edwardkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로컬 검증 완료 ✅

  • cargo test 788개 전체 통과 (Rust 코드 무변경)
  • 썸네일 스피너 정리: thumbDiv.textContent = '' 추가
  • options CSP: 인라인 스크립트 → options.js 분리
  • build.mjs: options.js 복사 추가

깔끔한 수정입니다! 감사합니다 👍

@edwardkim edwardkim merged commit 106224d into edwardkim:devel Apr 17, 2026
edwardkim added a commit that referenced this pull request Apr 19, 2026
본 v0.5.0 → v0.7.3 (라이브러리) / 0.2.0 (확장) 배포 주기에
머지된 외부 기여자 6명을 README 3개 변경 이력에 추가:

- @ahnbu — Ctrl+S file handle (PR #189, 기명시)
- @bapdodi — 회전 도형 리사이즈 + Flip (PR #192)
- @dreamworker0 — Windows CFB 경로 (PR #152)
- @marsimon — HWP 그림 효과 SVG (PR #149)
- @postmelee — 썸네일 + options CSP (PR #168)
- @seunghan91 — HWPX Serializer + 다수 (PR #170, #161, #163, #153, #154)

각 README 끝에 "기여자 감사" 섹션 추가 — 6명 일괄 인정.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@postmelee postmelee deleted the fix/chrome-clean-v2 branch May 2, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants